﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Category.aspx.cs" Inherits="admin_Category" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:Panel ID="Panel1" runat="server" GroupingText="Category">
            CategoryId:<asp:TextBox ID="txtCategoryId" runat="server"></asp:TextBox>
            <br />
            CategoryName:<asp:TextBox ID="txtCategoryName" runat="server"></asp:TextBox>
            <br />
            <asp:Button ID="btnSave" runat="server" onclick="Save_Click" Text="Save" />
            <asp:Button ID="btnEdit" runat="server" onclick="btnEdit_Click" Text="Edit" />
            <asp:Button ID="btnDelete" runat="server" Text="Delete" />
            <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
            <br />
            <br />
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                DataKeyNames="CategoryId" DataSourceID="SqlDataSource1">
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                    <asp:BoundField DataField="CategoryId" HeaderText="CategoryId" ReadOnly="True" 
                        SortExpression="CategoryId" />
                    <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" 
                        SortExpression="CategoryName" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ASPDB %>" 
                DeleteCommand="DELETE FROM [Category] WHERE [CategoryId] = @CategoryId" 
                InsertCommand="INSERT INTO [Category] ([CategoryId], [CategoryName]) VALUES (@CategoryId, @CategoryName)" 
                SelectCommand="SELECT * FROM [Category]" 
                UpdateCommand="UPDATE [Category] SET [CategoryName] = @CategoryName WHERE [CategoryId] = @CategoryId">
                <DeleteParameters>
                    <asp:Parameter Name="CategoryId" Type="String" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="CategoryId" Type="String" />
                    <asp:Parameter Name="CategoryName" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="CategoryName" Type="String" />
                    <asp:Parameter Name="CategoryId" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>
        </asp:Panel>
    
    </div>
    </form>
</body>
</html>
